package com.sina.weibo;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.sina.weibo.models.Account;
import com.sina.weibo.models.MBlog;
import com.sina.weibo.models.User;
import com.sina.weibo.view.MBlogListItemView;
import com.sina.weibo.view.MainListItemView;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

public class HomeListActivity extends HomeListBaseActivity
{
  public static final String ACTION_HOME_LIST_UPDATE = "com.sina.weibo.intent.action.ACTION_HOME_LIST_UPDATE";
  private static final int ADD_FAV_DONE = 3;
  public static final String KEY_DELETE_MOBLOG_RESULT = "delete_result";
  public static final String KEY_TOAST_ERROR = "ERROR";
  public static final String KEY_TOAST_STRING = "toast_words";
  private static final int LOADMORE_LIST = 1;
  private static final int REFRESH_LIST = 0;
  private static final int RELOAD_LIST = 2;
  private static final int SEND_TOAST = 4;
  private WeiboListAdapter adapter;
  private String blogId = null;
  Handler handler;
  private int mExpandItem = 0;
  private int mFinalPage = 0;
  private SinaWeiboDB mHomeDb = null;
  private ListView mLvHome;
  private BroadcastReceiver mNewMsgReceiver;
  Dialog mPgDialog;
  CustomToast mPgToast;
  private int mReadMode;
  private FetchDataTask mTask;
  private boolean mTaskFree = 1;

  public HomeListActivity()
  {
    HomeListActivity.1 local1 = new HomeListActivity.1(this);
    this.mNewMsgReceiver = local1;
    HomeListActivity.2 local2 = new HomeListActivity.2(this);
    this.handler = local2;
  }

  private void closeProgress(List<?> paramList, String paramString)
  {
    int i;
    if ((paramList != null) && (paramList.size() > 0))
      if ((this.mBackupList == null) || (this.mBackupList.size() == 0))
      {
        this.mBackupList = paramList;
        if (this.blogId != null)
        {
          i = 0;
          label46: int j = this.mList.size();
          if (i < j)
            break label211;
        }
      }
    label281: label429: 
    while (true)
    {
      return;
      Iterator localIterator = paramList.iterator();
      while (true)
      {
        if (!localIterator.hasNext())
        {
          List localList1 = this.mBackupList;
          MBlog[] arrayOfMBlog1 = new MBlog[0];
          MBlog[] arrayOfMBlog2 = (MBlog[])localList1.toArray(arrayOfMBlog1);
          HomeListActivity.11 local11 = new HomeListActivity.11(this);
          Arrays.sort(arrayOfMBlog2, local11);
          ArrayList localArrayList = new ArrayList();
          this.mBackupList = localArrayList;
          i = 0;
          while (true)
          {
            int k = arrayOfMBlog2.length;
            if (i >= k)
              break;
            List localList2 = this.mBackupList;
            MBlog localMBlog1 = arrayOfMBlog2[i];
            boolean bool1 = localList2.add(localMBlog1);
            i += 1;
          }
        }
        MBlog localMBlog2 = (MBlog)localIterator.next();
        boolean bool2 = this.mBackupList.add(localMBlog2);
      }
      label211: String str1 = ((MBlog)this.mBackupList.get(i)).mblogid;
      String str2 = this.blogId;
      if (str1.equals(str2))
      {
        this.mExpandItem = i;
        continue;
      }
      i += 1;
      break label46;
      String str3 = "";
      if (StaticInfo.mUser != null)
        if (paramList == null)
        {
          if (paramString != null)
            str3 = paramString;
        }
        else if (((this.mList == null) || (this.mList.size() == 0)) && ((this.mBackupList == null) || (this.mBackupList.size() == 0)))
        {
          String str4 = this.mCacheDir;
          User localUser = StaticInfo.mUser;
          List localList3 = Utils.loadHomeListFile(str4, localUser);
          this.mBackupList = localList3;
        }
      while (true)
      {
        if (TextUtils.isEmpty(str3))
          break label429;
        Message localMessage = new Message();
        localMessage.what = 4;
        Bundle localBundle = new Bundle();
        localBundle.putString("ERROR", str3);
        localMessage.setData(localBundle);
        boolean bool3 = this.handler.sendMessage(localMessage);
        break;
        str3 = getString(2131427376);
        break label281;
        str3 = getString(2131427402);
      }
    }
  }

  private void doItemMenu(String paramString)
  {
    Resources localResources = getResources();
    String str1 = localResources.getString(2131427510);
    if (paramString.equals(str1))
    {
      List localList1 = this.mList;
      int i = this.mExpandItem;
      MBlog localMBlog1 = (MBlog)localList1.get(i);
      MainTabActivity localMainTabActivity1 = this.mParent;
      Intent localIntent1 = Utils.forwardMBlog(this, localMBlog1);
      localMainTabActivity1.startActivity(localIntent1);
    }
    while (true)
    {
      return;
      String str2 = localResources.getString(2131427662);
      if (paramString.equals(str2))
      {
        List localList2 = this.mList;
        int j = this.mExpandItem;
        MBlog localMBlog2 = (MBlog)localList2.get(j);
        MainTabActivity localMainTabActivity2 = this.mParent;
        Intent localIntent2 = Utils.forwardSrcMBlog(this, localMBlog2);
        localMainTabActivity2.startActivity(localIntent2);
        continue;
      }
      String str3 = localResources.getString(2131427516);
      if (paramString.equals(str3))
      {
        new HomeListActivity.10(this).start();
        continue;
      }
      String str4 = localResources.getString(2131427514);
      MBlog localMBlog3;
      if (paramString.equals(str4))
      {
        List localList3 = this.mList;
        int k = this.mExpandItem;
        localMBlog3 = (MBlog)localList3.get(k);
        try
        {
          RPCHelper localRPCHelper1 = RPCHelper.getInstance(getApplication());
          User localUser1 = StaticInfo.mUser;
          String str5 = localMBlog3.favid;
          String str6 = localMBlog3.mblogid;
          if (!localRPCHelper1.deleteFavMBlog(localUser1, str5, str6))
            continue;
          boolean bool1 = this.mList.remove(localMBlog3);
          int[] arrayOfInt1 = StaticInfo.mTotals;
          int m = arrayOfInt1[5] - 1;
          arrayOfInt1[5] = m;
          this.mExpandItem = 0;
          ((WeiboListAdapter)this.mLvHome.getAdapter()).refresh();
        }
        catch (RPCHelper.HttpException localHttpException1)
        {
        }
        continue;
      }
      String str7 = localResources.getString(2131427515);
      if (paramString.equals(str7))
      {
        List localList4 = this.mList;
        int n = this.mExpandItem;
        localMBlog3 = (MBlog)localList4.get(n);
        try
        {
          RPCHelper localRPCHelper2 = RPCHelper.getInstance(getApplication());
          User localUser2 = StaticInfo.mUser;
          String str8 = localMBlog3.mblogid;
          if (!localRPCHelper2.deleteMBlog(localUser2, str8))
            continue;
          boolean bool2 = this.mList.remove(localMBlog3);
          int[] arrayOfInt2 = StaticInfo.mTotals;
          int i1 = arrayOfInt2[0] - 1;
          arrayOfInt2[0] = i1;
          this.mExpandItem = 0;
          ((WeiboListAdapter)this.mLvHome.getAdapter()).refresh();
        }
        catch (RPCHelper.HttpException localHttpException2)
        {
        }
        continue;
      }
      String str9 = localResources.getString(2131427511);
      if (paramString.equals(str9))
      {
        List localList5 = this.mList;
        int i2 = this.mExpandItem;
        MBlog localMBlog4 = (MBlog)localList5.get(i2);
        MainTabActivity localMainTabActivity3 = this.mParent;
        String str10 = localMBlog4.mblogid;
        String str11 = localMBlog4.uid;
        Intent localIntent3 = Utils.simpleComment(this, str10, str11);
        localMainTabActivity3.startActivity(localIntent3);
        continue;
      }
      String str12 = localResources.getString(2131427518);
      if (paramString.equals(str12))
      {
        Intent localIntent4 = new Intent(this, UserInfoActivity2.class);
        List localList6 = this.mList;
        int i3 = this.mExpandItem;
        MBlog localMBlog5 = (MBlog)localList6.get(i3);
        String str13 = localMBlog5.uid;
        Intent localIntent5 = localIntent4.putExtra("uid", str13);
        String str14 = localMBlog5.nick;
        Intent localIntent6 = localIntent4.putExtra("nick", str14);
        boolean bool3 = localMBlog5.vip;
        Intent localIntent7 = localIntent4.putExtra("vip", bool3);
        String str15 = StaticInfo.mUser.uid;
        Intent localIntent8 = localIntent4.putExtra("myuid", str15);
        this.mParent.startActivity(localIntent4);
        continue;
      }
      String str16 = localResources.getString(2131427508);
      if (paramString.equals(str16))
      {
        List localList7 = this.mList;
        int i4 = this.mExpandItem;
        localMBlog3 = (MBlog)localList7.get(i4);
        try
        {
          String str17 = this.mCacheDir;
          String str18 = localMBlog3.portrait;
          String str19 = Utils.checkCache(str17, str18);
          boolean bool4 = new File(str19).delete();
          ((WeiboListAdapter)this.mLvHome.getAdapter()).refresh();
        }
        catch (NullPointerException localNullPointerException1)
        {
        }
        continue;
      }
      String str20 = localResources.getString(2131427507);
      if (paramString.equals(str20))
      {
        List localList8 = this.mList;
        int i5 = this.mExpandItem;
        localMBlog3 = (MBlog)localList8.get(i5);
        try
        {
          String str21 = this.mCacheDir;
          String str22 = localMBlog3.pic;
          String str23 = Utils.checkCache(str21, str22);
          boolean bool5 = new File(str23).delete();
          ((WeiboListAdapter)this.mLvHome.getAdapter()).refresh();
        }
        catch (NullPointerException localNullPointerException2)
        {
        }
        continue;
      }
      if (paramString.startsWith("@"))
      {
        Intent localIntent9 = new Intent(this, UserInfoActivity2.class);
        String str24 = paramString.substring(1);
        Intent localIntent10 = localIntent9.putExtra("nick", str24);
        String str25 = StaticInfo.mUser.uid;
        Intent localIntent11 = localIntent9.putExtra("myuid", str25);
        Intent localIntent12 = localIntent9.putExtra("vip", 0);
        this.mParent.startActivity(localIntent9);
        continue;
      }
      if (paramString.startsWith("#"))
      {
        int i6 = paramString.length() - 1;
        String str26 = paramString.substring(1, i6);
        List localList9 = this.mList;
        deleteList(localList9);
        continue;
      }
      Uri localUri = Uri.parse(paramString);
      Intent localIntent13 = new Intent("android.intent.action.VIEW", localUri);
      this.mParent.startActivity(localIntent13);
    }
  }

  private boolean isNewCommer(int paramInt)
  {
    if ((paramInt != -1) && (this.mList != null) && (this.mList.size() != 0))
    {
      long l1 = ((MBlog)this.mList.get(paramInt)).time.getTime();
      long l2 = this.lastestItemTime;
      if (l1 <= l2);
    }
    for (int i = 1; ; i = 0)
      return i;
  }

  private void loadItemfromBackup()
  {
    if ((this.mBackupList == null) || (this.mBackupList.size() == 0));
    while (true)
    {
      return;
      if (this.mBackupList.size() > 25);
      for (int i = 25; ; i = this.mBackupList.size())
      {
        if (this.mList == null)
        {
          ArrayList localArrayList = new ArrayList();
          this.mList = localArrayList;
        }
        List localList1 = this.mBackupList;
        int j = i - 1;
        List localList2 = localList1.subList(0, j);
        if (!this.mBeReload)
          break label196;
        String str = this.mCacheDir;
        User localUser = StaticInfo.mUser;
        Utils.saveHomeListFile(localList2, str, localUser);
        List localList3 = this.mList;
        deleteList(localList3);
        int k = 0;
        if (localList2 != null)
          k = localList2.size();
        if (k == 0)
          break;
        boolean bool1 = this.mList.addAll(localList2);
        m = 0;
        while (m < k)
        {
          Object localObject1 = this.mBackupList.remove(0);
          m += 1;
        }
        break;
      }
      label196: int m = 0;
      while (m < i)
      {
        List localList4 = this.mList;
        MBlog localMBlog = (MBlog)this.mBackupList.get(0);
        boolean bool2 = localList4.add(localMBlog);
        Object localObject2 = this.mBackupList.remove(0);
        m += 1;
      }
    }
  }

  private void refreshHomeList()
  {
    ((WeiboListAdapter)this.mLvHome.getAdapter()).refresh();
    this.mLvHome.setFocusable(1);
    this.mLvHome.setFocusableInTouchMode(1);
    this.mLvHome.setVisibility(0);
  }

  private void reloadWeiboList()
  {
    reloadBegine(1);
    this.mBackupList.clear();
    this.mBeReload = 1;
    Intent localIntent1 = new Intent("sina.weibo.action.UPDATED");
    Intent localIntent2 = localIntent1.putExtra("NOTIFY_KEY", 10000);
    long l;
    if ((this.mList != null) && (this.mList.size() != 0))
      l = ((MBlog)this.mList.get(0)).time.getTime();
    for (this.lastestItemTime = l; ; this.lastestItemTime = 0L)
    {
      sendBroadcast(localIntent1);
      this.mNewCount = 0;
      if (this.mTaskFree)
      {
        FetchDataTask localFetchDataTask1 = new FetchDataTask(null);
        this.mTask = localFetchDataTask1;
        FetchDataTask localFetchDataTask2 = this.mTask;
        String[] arrayOfString = new String[1];
        arrayOfString[0] = "null";
        AsyncTask localAsyncTask = localFetchDataTask2.execute(arrayOfString);
      }
      ((WeiboListAdapter)this.mLvHome.getAdapter()).refresh();
      this.mExpandItem = 1;
      return;
    }
  }

  private void sendRefreshMessage(int paramInt)
  {
    Message localMessage = new Message();
    if (paramInt == 0);
    for (int i = 0; ; i = 1)
    {
      localMessage.what = i;
      boolean bool = this.handler.sendMessage(localMessage);
      return;
    }
  }

  private void showItemMenu(List<CharSequence> paramList)
  {
    AlertDialog.Builder localBuilder1 = new AlertDialog.Builder(this);
    List<CharSequence> localList = paramList;
    AlertDialog.Builder localBuilder2 = localBuilder1.setTitle(2131427362);
    CharSequence[] arrayOfCharSequence1 = new CharSequence[0];
    CharSequence[] arrayOfCharSequence2 = (CharSequence[])localList.toArray(arrayOfCharSequence1);
    HomeListActivity.9 local9 = new HomeListActivity.9(this, localList);
    AlertDialog.Builder localBuilder3 = localBuilder1.setItems(arrayOfCharSequence2, local9);
    localBuilder1.create().show();
  }

  protected void handleTitleBarEvent(int paramInt)
  {
    switch (paramInt)
    {
    default:
    case 1:
    case 0:
    }
    while (true)
    {
      return;
      MainTabActivity localMainTabActivity = this.mParent;
      Intent localIntent = Utils.editNewBlog(this);
      localMainTabActivity.startActivity(localIntent);
      continue;
      reloadList();
    }
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    IntentFilter localIntentFilter = new IntentFilter();
    localIntentFilter.addAction("com.sina.weibo.action.HOMENEW");
    BroadcastReceiver localBroadcastReceiver = this.mNewMsgReceiver;
    Intent localIntent = registerReceiver(localBroadcastReceiver, localIntentFilter);
    SinaWeiboDB localSinaWeiboDB = SinaWeiboDB.getInstance(this);
    this.mHomeDb = localSinaWeiboDB;
    String str1 = getString(2131427373);
    String str2 = StaticInfo.mUser.nick;
    String str3 = getString(2131427374);
    setTitleBar(1, str1, str2, str3);
    WeiboListAdapter localWeiboListAdapter1 = new WeiboListAdapter();
    this.adapter = localWeiboListAdapter1;
    ListView localListView1 = this.mlvBase;
    this.mLvHome = localListView1;
    ListView localListView2 = this.mLvHome;
    WeiboListAdapter localWeiboListAdapter2 = this.adapter;
    localListView2.setAdapter(localWeiboListAdapter2);
    this.mLvHome.setLongClickable(1);
    ListView localListView3 = this.mLvHome;
    HomeListActivity.3 local3 = new HomeListActivity.3(this);
    localListView3.setOnItemSelectedListener(local3);
    ListView localListView4 = this.mLvHome;
    HomeListActivity.4 local4 = new HomeListActivity.4(this);
    localListView4.setOnItemLongClickListener(local4);
    ListView localListView5 = this.mLvHome;
    HomeListActivity.5 local5 = new HomeListActivity.5(this);
    localListView5.setOnItemClickListener(local5);
    ListView localListView6 = this.mLvHome;
    HomeListActivity.6 local6 = new HomeListActivity.6(this);
    localListView6.setOnScrollListener(local6);
    String str4 = this.mCacheDir;
    User localUser = StaticInfo.mUser;
    List localList1 = Utils.loadHomeListFile(str4, localUser);
    this.mBackupList = localList1;
    ArrayList localArrayList = new ArrayList();
    this.mList = localArrayList;
    int i;
    int j;
    if (this.mBackupList != null)
    {
      i = this.mBackupList.size();
      j = 0;
    }
    while (true)
    {
      if (j >= i)
      {
        new IntentFilter().addAction("sina.weibo.action.UPDATEHOME");
        return;
      }
      List localList2 = this.mList;
      MBlog localMBlog = (MBlog)this.mBackupList.get(0);
      boolean bool = localList2.add(localMBlog);
      Object localObject = this.mBackupList.remove(0);
      j += 1;
    }
  }

  protected void onDestroy()
  {
    BroadcastReceiver localBroadcastReceiver = this.mNewMsgReceiver;
    unregisterReceiver(localBroadcastReceiver);
    super.onDestroy();
  }

  public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    if (paramInt == 4)
    {
      AlertDialog.Builder localBuilder1 = new AlertDialog.Builder(this);
      AlertDialog.Builder localBuilder2 = localBuilder1.setTitle(2131427444).setIcon(2130837926).setCancelable(0);
      HomeListActivity.7 local7 = new HomeListActivity.7(this);
      AlertDialog.Builder localBuilder3 = localBuilder2.setPositiveButton(2131427441, local7);
      HomeListActivity.8 local8 = new HomeListActivity.8(this);
      AlertDialog.Builder localBuilder4 = localBuilder3.setNegativeButton(2131427436, local8);
      AlertDialog localAlertDialog = localBuilder1.show();
    }
    boolean bool;
    for (int i = 1; ; bool = super.onKeyDown(paramInt, paramKeyEvent))
      return i;
  }

  public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    boolean bool = super.onOptionsItemSelected(paramMenuItem);
    return true;
  }

  protected void onPause()
  {
    if ((!this.mTaskFree) && (this.mTask != null) && (!this.mTask.isCancelled()))
    {
      boolean bool = this.mTask.cancel(1);
      if (this.mPgToast != null)
        this.mPgToast.cancel();
    }
    if ((isFinishing()) && (this.mList != null) && (this.mList.size() > 25))
    {
      StaticInfo.mTotals[0] = 1;
      int[] arrayOfInt = StaticInfo.mTotals;
      String str = this.mCacheDir;
      User localUser = StaticInfo.mUser;
      Utils.saveTotalFile(arrayOfInt, str, localUser);
    }
    super.onPause();
  }

  protected void onResume()
  {
    super.onResume();
    int i = getSharedPreferences("readmode", 0).getInt("readmode", 0);
    if (this.mReadMode != i)
    {
      this.mReadMode = i;
      this.adapter.notifyDataSetChanged();
    }
    boolean bool;
    if ((StaticInfo.mUser == null) || (MainTabActivity.mSetSwitchTop))
      if (MainTabActivity.mSetSwitchTop)
        if (MainTabActivity.mSetSwitchTop)
        {
          bool = false;
          MainTabActivity.mSetSwitchTop = bool;
          MainTabActivity localMainTabActivity = this.mParent;
          Intent localIntent = new Intent(this, SwitchUser.class);
          localMainTabActivity.startActivityForResult(localIntent, 0);
        }
    label203: 
    do
    {
      while (true)
      {
        return;
        bool = true;
        break;
        bool = MainTabActivity.mSetSwitchTop;
        break;
        String str1 = getString(2131427373);
        String str2 = StaticInfo.mUser.nick;
        String str3 = getString(2131427374);
        setTitleBar(1, str1, str2, str3);
        if ((!MainTabActivity.mHomeReload) || (StaticInfo.mUser == null))
          break label203;
        if ((this.mList == null) || (this.mList.size() == 0))
          this.mLvHome.setVisibility(4);
        if (this.mTaskFree)
          reloadWeiboList();
        MainTabActivity.ReverseReloadVariant();
      }
      if (((this.mList != null) && (this.mList.size() != 0)) || (StaticInfo.mUser == null))
        continue;
      this.mLvHome.setVisibility(4);
      String str4 = this.mCacheDir;
      User localUser = StaticInfo.mUser;
      List localList1 = Utils.loadHomeListFile(str4, localUser);
      this.mBackupList = localList1;
      loadItemfromBackup();
      if ((this.mList == null) || (this.mList.size() == 0))
        break label417;
      sendRefreshMessage(0);
    }
    while ((!this.mTaskFree) || ((this.mBackupList != null) && (this.mBackupList.size() != 0)));
    this.mExpandItem = 1;
    this.mTaskFree = 0;
    FetchDataTask localFetchDataTask1 = new FetchDataTask(null);
    this.mTask = localFetchDataTask1;
    List localList2 = this.mList;
    int j = this.mList.size() - 1;
    MBlog localMBlog = (MBlog)localList2.get(j);
    if (localMBlog == null);
    for (String str5 = "null"; ; str5 = localMBlog.mblogid)
    {
      FetchDataTask localFetchDataTask2 = this.mTask;
      String[] arrayOfString = new String[1];
      arrayOfString[0] = str5;
      AsyncTask localAsyncTask = localFetchDataTask2.execute(arrayOfString);
      break;
      label417: if (!this.mTaskFree)
        break;
      reloadWeiboList();
      break;
    }
  }

  protected void onStart()
  {
    super.onStart();
  }

  protected void reloadList()
  {
    if ((this.mBeReload) && (!this.mTaskFree));
    while (true)
    {
      return;
      if ((!this.mTaskFree) && (this.mTask != null) && (!this.mTask.isCancelled()))
        boolean bool1 = this.mTask.cancel(0);
      Message localMessage = new Message();
      localMessage.what = 2;
      boolean bool2 = this.handler.sendMessage(localMessage);
    }
  }

  class FetchDataTask extends AsyncTask<String, Integer, List<?>>
  {
    String error;

    private FetchDataTask()
    {
    }

    protected List<?> doInBackground(String[] paramArrayOfString)
    {
      String str1;
      if (paramArrayOfString[0] == "null")
        str1 = null;
      int i;
      label48: Object[] arrayOfObject1;
      Object localObject1;
      while (true)
      {
        if ((HomeListActivity.this.mBeReload) || (HomeListActivity.this.mList == null) || (HomeListActivity.this.mList.size() == 0))
        {
          i = 50;
          arrayOfObject1 = (Object[])0;
        }
        try
        {
          if ((!StaticInfo.mUsername.equals("")) && (!StaticInfo.mPassword.equals("")))
          {
            if (StaticInfo.mUser == null)
            {
              RPCHelper localRPCHelper1 = RPCHelper.getInstance(HomeListActivity.this.getApplication());
              String str2 = StaticInfo.mUsername;
              String str3 = StaticInfo.mPassword;
              StaticInfo.mUser = localRPCHelper1.login(str2, str3);
              if ((StaticInfo.mUser.gsid == null) || (StaticInfo.mUser.uid == null))
              {
                StaticInfo.mUser = null;
                localObject1 = null;
                return localObject1;
                str1 = paramArrayOfString[0];
                continue;
                i = 25;
                break label48;
              }
              List localList1 = AccountHelper.loadAccounts(HomeListActivity.this);
              Account localAccount = new Account();
              String str4 = StaticInfo.mUsername;
              localAccount.user = str4;
              String str5 = StaticInfo.mPassword;
              localAccount.pass = str5;
              String str6 = StaticInfo.mUser.nick;
              localAccount.nick = str6;
              AccountHelper.addOrSortAccount(localList1, localAccount);
              AccountHelper.saveAccounts(HomeListActivity.this, localList1);
              User localUser1 = StaticInfo.mUser;
              String str7 = HomeListActivity.this.mCacheDir;
              HomeListActivity localHomeListActivity1 = HomeListActivity.this;
              Utils.saveUserFile(localUser1, str7, localHomeListActivity1);
            }
            RPCHelper localRPCHelper2 = RPCHelper.getInstance(HomeListActivity.this.getApplication());
            User localUser2 = StaticInfo.mUser;
            int j = MainTabActivity.mPrefPictureSize;
            arrayOfObject1 = localRPCHelper2.getHomeBlogList(localUser2, j, str1, i);
            if (HomeListActivity.this.blogId != null)
            {
              RPCHelper localRPCHelper3 = RPCHelper.getInstance(HomeListActivity.this.getApplication());
              User localUser3 = StaticInfo.mUser;
              String str8 = HomeListActivity.this.blogId;
              int k = MainTabActivity.mPrefPictureSize;
              Object[] arrayOfObject2 = localRPCHelper3.getSingleMBlog(localUser3, str8, k);
              if (arrayOfObject2[1] != 0)
              {
                List localList2 = (List)arrayOfObject1[1];
                Object localObject2 = arrayOfObject2[1];
                boolean bool1 = localList2.add(localObject2);
              }
            }
            if (!HomeListActivity.this.mBeReload);
          }
          else
          {
            switch (((Integer)arrayOfObject1[0]).intValue() / 25)
            {
            default:
            case 0:
              while (true)
              {
                int[] arrayOfInt = StaticInfo.mTotals;
                String str9 = HomeListActivity.this.mCacheDir;
                User localUser4 = StaticInfo.mUser;
                Utils.saveTotalFile(arrayOfInt, str9, localUser4);
                HomeListActivity localHomeListActivity2 = HomeListActivity.this;
                List localList3 = (List)arrayOfObject1[1];
                String str10 = this.error;
                localHomeListActivity2.closeProgress(localList3, str10);
                localObject1 = (List)arrayOfObject1[1];
                break;
                StaticInfo.mTotals[0] = 0;
                HomeListActivity.this.mFinalPage = 0;
              }
            case 1:
            case 2:
            }
          }
        }
        catch (RPCHelper.HttpException localHttpException)
        {
          while (true)
          {
            HomeListActivity localHomeListActivity3 = HomeListActivity.this;
            Throwable localThrowable = Utils.getRootCause(localHttpException);
            String str11 = Utils.translationThrowable(localHomeListActivity3, localThrowable);
            this.error = str11;
            boolean bool2 = cancel(1);
            localObject1 = null;
            continue;
            StaticInfo.mTotals[0] = 1;
            HomeListActivity.this.mFinalPage = 0;
            continue;
            StaticInfo.mTotals[0] = 1;
            HomeListActivity.this.mFinalPage = 1;
          }
          localObject1 = HomeListActivity.this;
          if (arrayOfObject1[0] == 0)
            break label643;
        }
      }
      int m;
      if (((Integer)arrayOfObject1[0]).intValue() < i)
        m = 0;
      while (true)
      {
        ((HomeListActivity)localObject1).mFinalPage = m;
        break;
        m = 1;
        continue;
        label643: m = 0;
      }
    }

    protected void onCancelled()
    {
      if (HomeListActivity.this.mPgToast != null)
        HomeListActivity.this.mPgToast.cancel();
      HomeListActivity.this.mParent.setProgressBarIndeterminateVisibility(0);
      if (((HomeListActivity.this.mList == null) || (HomeListActivity.this.mList.size() == 0)) && ((HomeListActivity.this.mBackupList == null) || (HomeListActivity.this.mBackupList.size() == 0)))
      {
        HomeListActivity localHomeListActivity1 = HomeListActivity.this;
        String str1 = HomeListActivity.this.mCacheDir;
        User localUser = StaticInfo.mUser;
        List localList = Utils.loadHomeListFile(str1, localUser);
        localHomeListActivity1.mBackupList = localList;
      }
      if ((HomeListActivity.this.mList == null) || (HomeListActivity.this.mList.size() == 0))
      {
        HomeListActivity.this.mLvHome.setVisibility(4);
        HomeListActivity localHomeListActivity2 = HomeListActivity.this;
        String str2 = HomeListActivity.this.getString(2131427386);
        Toast.makeText(localHomeListActivity2, str2, 0).show();
      }
      do
      {
        HomeListActivity.this.mTaskFree = 1;
        return;
      }
      while (!HomeListActivity.this.reloadBegine);
      HomeListActivity localHomeListActivity3 = HomeListActivity.this;
      if (HomeListActivity.this.mBeReload);
      for (int i = 1; ; i = 0)
      {
        localHomeListActivity3.reloadEnd(i);
        break;
      }
    }

    protected void onPostExecute(List<?> paramList)
    {
      if ((HomeListActivity.this.mBeReload) && (HomeListActivity.this.mBackupList != null) && (HomeListActivity.this.mBackupList.size() != 0))
      {
        String str1 = HomeListActivity.this.mCacheDir;
        User localUser = StaticInfo.mUser;
        Utils.cleanHomeListFile(str1, localUser);
        HomeListActivity.this.loadItemfromBackup();
        HomeListActivity.this.sendRefreshMessage(0);
      }
      if (((HomeListActivity.this.mList == null) || (HomeListActivity.this.mList.size() == 0)) && ((HomeListActivity.this.mBackupList == null) || (HomeListActivity.this.mBackupList.size() == 0)))
      {
        HomeListActivity.this.mLvHome.setVisibility(4);
        if ((paramList != null) && (StaticInfo.mUser != null))
        {
          HomeListActivity localHomeListActivity1 = HomeListActivity.this;
          String str2 = HomeListActivity.this.getString(2131427386);
          Toast.makeText(localHomeListActivity1, str2, 0).show();
        }
      }
      if ((HomeListActivity.this.mBeReload) && (HomeListActivity.this.mList != null) && (HomeListActivity.this.mList.size() != 0))
        HomeListActivity.this.mLvHome.setSelection(1);
      HomeListActivity.this.mBeReload = 0;
      if (HomeListActivity.this.mPgToast != null)
        HomeListActivity.this.mPgToast.cancel();
      HomeListActivity.this.mParent.setProgressBarIndeterminateVisibility(0);
      HomeListActivity localHomeListActivity2;
      if (HomeListActivity.this.reloadBegine)
      {
        localHomeListActivity2 = HomeListActivity.this;
        if (!HomeListActivity.this.mBeReload)
          break label299;
      }
      label299: for (int i = 1; ; i = 0)
      {
        localHomeListActivity2.reloadEnd(i);
        HomeListActivity.this.mTaskFree = 1;
        return;
      }
    }

    protected void onPreExecute()
    {
      HomeListActivity.this.mTaskFree = 0;
      HomeListActivity.this.mParent.setProgressBarIndeterminateVisibility(1);
      if ((HomeListActivity.this.mList == null) || (HomeListActivity.this.mList.size() == 0))
      {
        if (HomeListActivity.this.mPgToast == null)
        {
          HomeListActivity localHomeListActivity1 = HomeListActivity.this;
          HomeListActivity localHomeListActivity2 = HomeListActivity.this;
          CustomToast localCustomToast = Utils.createProgressCustomToast(2131427419, localHomeListActivity2);
          localHomeListActivity1.mPgToast = localCustomToast;
        }
        HomeListActivity.this.mPgToast.show();
      }
    }

    protected void onProgressUpdate(Integer[] paramArrayOfInteger)
    {
    }
  }

  class WeiboListAdapter extends BaseAdapter
  {
    public WeiboListAdapter()
    {
    }

    public int getCount()
    {
      int i;
      if (HomeListActivity.this.mList == null)
        i = 0;
      while (true)
      {
        return i;
        if ((StaticInfo.mTotals != null) && (StaticInfo.mTotals[0] == 0))
        {
          i = HomeListActivity.this.mList.size() + 1;
          continue;
        }
        i = HomeListActivity.this.mList.size() + 2;
      }
    }

    public Object getItem(int paramInt)
    {
      return Integer.valueOf(paramInt);
    }

    public long getItemId(int paramInt)
    {
      return paramInt;
    }

    public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
    {
      paramInt += -1;
      int i = paramInt;
      int j = -1;
      if (i == j);
      for (Object localObject1 = HomeListActivity.this.getReloadView(); ; localObject1 = HomeListActivity.this.getLoadMoreView())
      {
        return localObject1;
        int k = HomeListActivity.this.mList.size();
        int m = paramInt;
        int n = k;
        if (m != n)
          break;
      }
      int i1 = 1;
      int i2 = 0;
      String str1;
      label114: Object localObject2;
      if (StaticInfo.mUser == null)
      {
        List localList1 = HomeListActivity.this.mList;
        int i3 = paramInt;
        str1 = ((MBlog)localList1.get(i3)).uid;
        List localList2 = HomeListActivity.this.mList;
        int i4 = paramInt;
        String str2 = ((MBlog)localList2.get(i4)).uid;
        String str3 = str1;
        if (!str2.equals(str3))
          break label276;
        int i5 = 1;
        label161: if (paramView != null)
          break label283;
        HomeListActivity localHomeListActivity1 = HomeListActivity.this;
        ListView localListView1 = HomeListActivity.this.mLvHome;
        List localList3 = HomeListActivity.this.mList;
        int i7 = paramInt;
        MBlog localMBlog1 = (MBlog)localList3.get(i7);
        HomeListActivity localHomeListActivity2 = HomeListActivity.this;
        int i8 = paramInt;
        boolean bool1 = localHomeListActivity2.isNewCommer(i8);
        int i9 = HomeListActivity.this.mReadMode;
        localObject2 = new MBlogListItemView(localHomeListActivity1, localListView1, localMBlog1, i1, i2, i5, bool1, i9);
      }
      while (true)
      {
        localObject1 = localObject2;
        break;
        str1 = StaticInfo.mUser.uid;
        break label114;
        label276: int i6 = 0;
        break label161;
        label283: localObject2 = paramView;
        try
        {
          MainListItemView localMainListItemView = (MainListItemView)localObject2;
          List localList4 = HomeListActivity.this.mList;
          int i10 = paramInt;
          Object localObject3 = localList4.get(i10);
          HomeListActivity localHomeListActivity3 = HomeListActivity.this;
          int i11 = paramInt;
          boolean bool2 = localHomeListActivity3.isNewCommer(i11);
          int i12 = HomeListActivity.this.mReadMode;
          int i13 = i1;
          int i14 = i2;
          localMainListItemView.update(localObject3, i13, i14, bool2, i12);
        }
        catch (Exception localException)
        {
          HomeListActivity localHomeListActivity4 = HomeListActivity.this;
          ListView localListView2 = HomeListActivity.this.mLvHome;
          List localList5 = HomeListActivity.this.mList;
          int i15 = paramInt;
          MBlog localMBlog2 = (MBlog)localList5.get(i15);
          HomeListActivity localHomeListActivity5 = HomeListActivity.this;
          int i16 = paramInt;
          boolean bool3 = localHomeListActivity5.isNewCommer(i16);
          int i17 = HomeListActivity.this.mReadMode;
          localObject2 = new MBlogListItemView(localHomeListActivity4, localListView2, localMBlog2, i1, i2, i6, bool3, i17);
        }
      }
    }

    public int getViewTypeCount()
    {
      if (HomeListActivity.this.mList == null);
      for (int i = 1; ; i = 4)
        return i;
    }

    public void refresh()
    {
      notifyDataSetChanged();
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     com.sina.weibo.HomeListActivity
 * JD-Core Version:    0.6.0
 */